package com.java.service.impl.center;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.java.mapper.UsersDao;
import com.java.pojo.Users;
import com.java.pojo.bo.center.CenterUserBO;
import com.java.service.center.CenterUsersService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @author jl
 * Created on 2020/10/19
 */
@Service("centerUsersService")
public class CenterUsersServiceImpl extends ServiceImpl<UsersDao, Users> implements CenterUsersService {

    @Override
    public Users queryUserByUserId(String userId) {
        return this.baseMapper.selectById(userId);
    }

    @Override
    public Users updateUserInfo(String userId, CenterUserBO centerUserBO) {
        Users updateUser = new Users();
        BeanUtils.copyProperties(centerUserBO, updateUser);
        updateUser.setId(userId);
        updateUser.setUpdatedTime(new Date());
        this.updateById(updateUser);
        return queryUserByUserId(userId);
    }

    @Override
    public Users updateUserFace(String userId, String finalUserFaceUrl) {
        Users updateUser = new Users();
        updateUser.setId(userId);
        updateUser.setFace(finalUserFaceUrl);
        updateUser.setUpdatedTime(new Date());
        this.updateById(updateUser);
        return queryUserByUserId(userId);
    }


}
